﻿using System.Linq;
using ZilLion.Service.Core.DapperWrapper;
using ZilLion.Service.Core.DapperWrapper.SqlServer;
using ZilLion.Service.WeChatMall.Domain.Entitys.AppInfo;
using ZilLion.Service.WeChatMall.Domain.Repositorys.Interface.AppInfo;

namespace ZilLion.Service.WeChatMall.Domain.Repositorys.AppInfo
{
    public class AppRaInfoReponsitory : SqlServerRespository<AppRaInfoEntity>, IAppRaInfoReponsitory
    {
        public AppRaInfoReponsitory()
        {
            Context = new WechatMallContext();
        }
        public AppRaInfoEntity GetRaInfo(string appid)
        {
            var querysql = DapperHelper.CreateColSqlByMap<AppRaInfoEntity>();
            var sql = $@"SELECT {querysql} FROM apprainfo 
            WHERE appid=@appid";
            var result = GetList(sql, new { appid }).FirstOrDefault();
            return result;
        }

        public void AddInfo(AppRaInfoEntity entity, UnitOfWork unit = null)
        {
            Add(entity, unit);
        }

        public void RemoveInfo(AppRaInfoEntity entity, UnitOfWork unit = null)
        {
            Remove(entity, unit);
        }

        public void EditInfo(AppRaInfoEntity entity, UnitOfWork unit = null)
        {
            Modify(entity, unit);
        }
    }
}